import React, { Component } from 'react'

// 引入中央事件总线
import eventbus from './eventbus';
export default class Son2 extends Component {
    state = {
        words: 'hello'
    }
    render() {
        return (
            <div>Son2--{this.state.words}</div>
        )
    };
    componentDidMount(props, state) {
        eventbus.on('myevent', (data) => {
            console.log('data', data);
            this.setState((state) => {
                state.words = data
                return state   // 该return 对象最后合并 当前组件的state,不是替换
            })
        })

    }
}
